﻿Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Menu
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.Utils.Menu
Imports DevExpress.XtraSplashScreen

Public Class TonKho1
    Private Sub TinhTonKho()
        If Me.RadioGroup1.SelectedIndex = 0 Then
            Me.IGridView1.setTitle("Tồn kho theo lô (" & Format(CDate(TuNgayIDateEdit.EditValue), "dd/MM/yyyy") & "-" & Format(CDate(DenNgayIDateEdit.EditValue), "dd/MM/yyyy") & ")")
            Me.GetTonKho_Lo_HanDung_ThucTableAdapter.Fill(Me.PCV_CLINICDataSetTongHop.getTonKho_Lo_HanDung_Thuc, CDate(Me.TuNgayIDateEdit.EditValue), CDate(DenNgayIDateEdit.EditValue), "TL")
        Else
            Me.IGridView1.setTitle("Tồn kho tổng hợp ( " & Format(CDate(TuNgayIDateEdit.EditValue), "dd/MM/yyyy") & "-" & Format(CDate(DenNgayIDateEdit.EditValue), "dd/MM/yyyy") & ")")
            Me.GetTonKho_Lo_HanDung_ThucTableAdapter.Fill(Me.PCV_CLINICDataSetTongHop.getTonKho_Lo_HanDung_Thuc, CDate(Me.TuNgayIDateEdit.EditValue), CDate(DenNgayIDateEdit.EditValue), "")
        End If
        Me.IGridView1.ExpandAllGroups()
    End Sub
    Private Sub LoadDuLieu()
        SplashScreenManager.ShowForm(GetType(WaitForm1))
        Me.DMThoiGianTableAdapter.Fill(Me.PCV_CLINICDataSet_Don.DMThoiGian)
        Me.TuNgayIDateEdit.EditValue = getNgayDauThang(Today)
        Me.DenNgayIDateEdit.EditValue = getNgayCuoiThang(Today)
        TinhTonKho()
        Me.setHeaderFooter(Main.TenDoanhNghiep.ToString, Main.DiaChiDoanhNghiep.ToString)
        SplashScreenManager.CloseForm()
    End Sub
    Private Sub TonKho1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.DMThoiGianISearchLookupEdit.EditValue = "TN"
        LoadDuLieu()
    End Sub

    Protected Overrides Sub BarButtonItemLamTuoi_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemLamTuoi.ItemClick
        TinhTonKho()
    End Sub
    Public Sub New()
        InitializeComponent()
        Me.setObj(Me.GetTonKhoLoHanDungThucBindingSource)
    End Sub

    Private Sub RadioGroup1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadioGroup1.SelectedIndexChanged
        If Me.RadioGroup1.SelectedIndex = 0 Then
            Me.colsolo.Visible = True
            Me.colhsd.Visible = True
            Me.colsolo.GroupIndex = 1
            Me.colhsd.GroupIndex = 2
            TinhTonKho()
        Else
            TinhTonKho()
            Me.colsolo.Visible = False
            Me.colhsd.Visible = False
            Me.colsolo.GroupIndex = -1
            Me.colhsd.GroupIndex = -1
            TinhTonKho()
        End If
        Me.IGridView1.ExpandAllGroups()
    End Sub
    Private Sub DMThoiGianISearchLookupEdit_EditValueChanged(sender As Object, e As System.EventArgs) Handles DMThoiGianISearchLookupEdit.EditValueChanged
        setDMThoiGian(Me.DMThoiGianISearchLookupEdit, TuNgayIDateEdit, DenNgayIDateEdit)
        Me.BarButtonItemLamTuoi.PerformClick()
    End Sub
    Private Sub BarButtonItemBaoCao_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemBaoCao.ItemClick
        Me.IGridView1.inNhanh()
    End Sub
End Class
